﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;

namespace Chaos.commands
{
    public class showscreen : ICommand
    {
        public event EventHandler CanExecuteChanged
        {
            add { CommandManager.RequerySuggested += value; }
            remove { CommandManager.RequerySuggested -= value; }
        }

        public virtual bool CanExecute(object parameter)
        {
            return true;
        }

        public virtual void Execute(object parameter)
        {
            String screen = parameter as String;
            if (screen != null)
            {
                view.manager m = System.Windows.Application.Current.FindResource("view_manager") as view.manager;
                if (m != null)
                {
                    MainWindow w = m.Controls["main_window"] as MainWindow;
                    if (w != null)
                    {
                        if (screen == "GameScreen")
                        {
                            w.ScreenGrid_show(w.GameScreen);
                        }

                        if (screen == "LobbyScreen")
                        {
                            w.ScreenGrid_show(w.LobbyScreen);
                        }
                    }
                    
                }               
            }
        }
    }
}
